<template>
  <div>
    <input v-focus="{name:'llx',color: 'red'}" />
    <p class="title">{{ msg }}</p>
  </div>
</template>

<script>
export default {
  name: "page1",
  data() {
    return {
      msg: "page1",
    };
  },
  beforeCreate() {
  },
  directives: {
    focus: {
      // 指令的定义
      inserted: function (el,binding) {
          el.value= binding.value.name
          el.style.color=  binding.value.color
        el.focus();
      }
    },
  },
};
</script>

<style scoped>
.title {
  font-size: 26px;
  margin: 10px 0 0;
}
</style>
